#!/bin/bash

# 提交者的邮箱地址
author_email="roy@god.com"

IFS='@' read -ra parts <<<"$author_email"
author_name="${parts[0]}"

# 获取所有提交的文件路径
file_paths=$(git log --author="$author_email" --pretty=format: --name-only | sort | uniq)

echo "用户 $author_email 提交过的文件路径:"

fp=./"${author_name}Script.txt"

fp_tmp=./"${author_name}TmpScript.txt"

echo "$file_paths" >"$fp"
echo -n "" >"$fp_tmp"

while IFS= read -r file_path; do
    if [ -z "$file_path" ]; then
        echo "字符串为空"
    else
        if [ -f "../$file_path" ]; then
            echo "$file_path" >>"$fp_tmp"
        else
            echo "文件不存在: $file_path"
        fi
    fi
done <"$fp"

rm -f "$fp"

mv "$fp_tmp" "$fp"
